﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Edu.Application.Model.RequestModel;
using EStart.Infrastructure.ClientData;
using Edu.Application.Implements;
using Edu.Application.Interfaces;
using Edu.Api.Authentication;
using EStart.Infrastructure.Domain;
using Edu.Application.Model.Messaging;
using Edu.Application.Model.Models;

namespace Edu.Api.Controllers
{
    [Produces("application/json")]
    [Route("api/rolegroup")]
    public class RoleGroupController : APIController
    {
        private readonly IRoleGroupService _Service;

        public RoleGroupController(IRoleGroupService Service)
        {
            _Service = Service;
        }

        [HttpPost("save")]
        public async Task<ApiResult<string>> Save([FromBody]RoleGroupModel request)
        {
            return await _Service.SaveAsync(request);
        }


        [HttpPost("getpages")]
        public async Task<ApiResult<Page<RoleGroupModel>>> GetPages([FromBody]RoleGroupPage request)
        {
            return await _Service.GetPagesAsync(request);
        }


        [HttpGet("getdetail")]
        public ApiResult<RoleGroupModel> GetDetail(string guid)
        {
            var schoolGuid = Guid.Parse(guid);
            return _Service.GetDetail(schoolGuid);
        }


        [HttpPost("delete")]
        public ApiResult<string> Delete([FromBody]RoleGroupModel request)
        {
            var schoolGuid = Guid.Parse(request.guid);
            return _Service.Delete(schoolGuid);
        }
        [HttpGet("getcheckmodel")]
        public async Task<ApiResult<List<CheckModel>>> GetCheckModel()
        {

            return await _Service.GetCheckModelAsync();
        }
    }
}